import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

public class ResultTableModel extends AbstractTableModel {
	private static final long serialVersionUID = 1L;
	private String[] columnNames = {"Qty", "Artist", "Title", "Length", "Bitrate", "Size (MB)", "Get file"};
	private Class[] columnTypes = {Integer.class, String.class, String.class, String.class, Integer.class, Double.class, String.class};
	private ArrayList<Song> data;

	public ResultTableModel(ArrayList<Song> data) {
		super();
		this.data = data;
	}
	
	public String getColumnName(int columnIndex) {
		return columnNames[columnIndex];
	}
	
	public Class<?> getColumnClass(int columnIndex) {
		return String.class;
	}
	
	public int getColumnCount() {
		return columnNames.length;
	}

	public int getRowCount() {
		return data.size();
	}

	public Object getValueAt(int rowIndex, int columnIndex) {
		Song s = (Song)data.get(rowIndex);
		switch(columnIndex) {
		case 0:
			return s.getQuantity();
		case 1:
			return s.getArtist();
		case 2:
			return s.getTitle();
		case 3:
			return s.getFormattedDuration();
		case 4:
			return s.getBitrate();
		case 5:
			return s.getSize();
		case 6:
			return "Download";
		}
		return null;
	}


}
